Difference between NULL and Undefined in JavaScript

Both null and undefined represent the absence of a value in JavaScript, but they are different in purpose and use.

1. Null

Example:


let value = null;
console.log(value); 
    

Output: null

2. Undefined

Example:


let value;
console.log(value);
    

Output: undefined